'''
Created on Apr 12, 2012

@author: dolphinigle
'''
import unittest
import sha1
import elgamal

class Test(unittest.TestCase):
  def testElgamal(self):
    message = sha1.CalculateSHA1([0, 1, 1, 0, 0, 1, 1, 1, 0, 0])
    print 'Message:', message
    
    (p, g, x, y) = elgamal.GenKey()
    sign = elgamal.Sign(p, g, x, message)
    print 'Signature:', sign
    
    self.assertTrue(elgamal.Verify(p, g, y, sign, message))
    message = sha1.CalculateSHA1([0, 1, 1, 1, 0, 1, 1, 1, 0, 0])
    self.assertFalse(elgamal.Verify(p, g, y, sign, message))

if __name__ == "__main__":
  #import sys;sys.argv = ['', 'Test.testName']
  unittest.main()